<?php
/*
 * Zend_Db_Table_Abstract class
 */
require_once ('Zend/Db/Table/Abstract.php');

/**
 * Classes class, for classes table in the database.
 * 
 * @author Philip Gabbert <gp@gpcentre.net>
 */
class Npcs extends Zend_Db_Table_Abstract {

   /*
    * Table name within the DB.
    */
   protected $name = 'npcs';

   /**
    * Maps NPCs to Zones
    */
   protected $_referenceMap    = array(
        'Zones' => array(
            'columns'           => 'zones_id',
            'refTableClass'     => 'Zones',
            'refColumns'        => 'id'
        ),
    );

   /**
    * Overwrite to automatically insert db array into constructor
    * TODO: Add more functionalit to this to insure nothing breaks.
    */
   public function __construct() {
      parent::__construct( array('db' => 'db') );
   }

   /**
    * Overwrite the method so we can tack on the table prefix.
    */
   protected function _setupTableName() {

      /* Get the prefix value from the config */
      $prefix = Zend_Registry::get( 'config' )->database->table->prefix;
      $this->_name = $prefix . $this->name;
      parent::_setupTableName(); // Always call parent, just to be sure.
   }
   
   /**
    * Returns all rows within the table.
    */
   public static function getAll($where = null, $order = null, $count = null, $offset = null) {
      $self = new Zones();
      $return = $self->fetchAll($where, $order, $count, $offset);
      return $return->toArray();
   }
   
}
?>